package collections;

import java.util.LinkedList;
import java.util.Queue;

public class QueueTest {

	public static void main(String[] args) {
		Queue<String> queue = new LinkedList<String>();
		queue.add("apple");		
		queue.add("cat");
		queue.add("dog");
		queue.add("ball");
		
		System.out.println(queue+" Size: "+queue.size());
		System.out.println("After offer: " + queue.offer("egg"));
		System.out.println(queue+" Size: "+queue.size());
		System.out.println("After add: " + queue.add("fire"));
		System.out.println(queue+" Size: "+queue.size());
		System.out.println("Retrieves head bt doesnt remove it: "+queue.peek());
		System.out.println("Retrieves head and REMOVES it: " + queue.poll());
		System.out.println(queue+" Size: "+queue.size());
		System.out.println("After duplicate value: "+queue.add("dog"));//Duplicates allowed in list
		System.out.println(queue+" Size: "+queue.size());
		System.out.println(queue.add(null));//null values are allowed here.
		System.out.println(queue.add(null));
		System.out.println(queue+" Size: "+queue.size());
	}

}
